package com.bit.example.principle;

import com.bit.example.principle.model.Person;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Main {
    public static void main(String[] args) throws Exception{
//        Class<?> clazz = Class.forName("org.springframework.boot.autoconfigure.aop.AopAutoConfiguration");
//        Object o = clazz.getDeclaredConstructor().newInstance();


//        Class<?> clazz = Class.forName("com.bit.example.principle.model.Person");
//        Object o = clazz.getDeclaredConstructor().newInstance();
//        System.out.println((Person)o);

        Class<?> clazz2 = Class.forName("com.bit.example.principle.model.Person");
        Object o1 = clazz2.getDeclaredConstructor(String.class).newInstance("zhangsan");
        System.out.println((Person)o1);


        Method method = clazz2.getDeclaredMethod("printNum", Integer.class);
        method.setAccessible(true);
        method.invoke(o1, 5);

        Field field = clazz2.getDeclaredField("name");
        field.setAccessible(true);
        Object name = field.get(o1);
        System.out.println(name);

    }
}
